package com.qf.shrio2203.untils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
public class ApplicationContextUtils implements ApplicationContextAware {

    private static  ApplicationContext cxt;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        cxt=applicationContext;
    }

    public static Object getBean(String beanName){
        return cxt.getBean(beanName);
    }

    public static <T> T getBean(Class<T> clazz){
        return cxt.getBean(clazz);
    }
}
